package com.qkbb.admin.kuibu.qkbb.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.qkbb.admin.kuibu.R;

public class TitleBarView extends RelativeLayout {

	private Context mcontext;
	private ImageButton ib_leftButton;
	private ImageButton ib_rightbButton;
	private TextView tv_centertTextView;
	private RelativeLayout layout;
	
	public TitleBarView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		// TODO Auto-generated constructor stub
		mcontext=context;
		initview();
	}
	public TitleBarView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
		mcontext=context;
		initview();
	}
	public TitleBarView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		mcontext=context;
		initview();
	}
	
	private void initview(){
		LayoutInflater.from(mcontext).inflate(R.layout.title_bar,this);
		ib_leftButton=(ImageButton) findViewById(R.id.ib_left_titlebar);
		ib_rightbButton=(ImageButton) findViewById(R.id.ib_right_titlebar);
		tv_centertTextView=(TextView) findViewById(R.id.tv_titlebar);
		layout= (RelativeLayout) findViewById(R.id.relative_titlebar);
	}
	public void setTextSize(float size){
		tv_centertTextView.setTextSize(size);
	}
	public void setCenterTexiView(String string){
		tv_centertTextView.setText(string);
	}
	public void setColor(int color){
		layout.setBackgroundResource(color);
	}
	public void setLeftButton(int id){
		ib_leftButton.setVisibility(View.VISIBLE);
		ib_leftButton.setImageResource(id);
	}
	public void settextColor(int color){
		tv_centertTextView.setTextColor(color);
		//tv_centertTextView.setBackgroundColor(color);
	}
	public void setRightButton(int id){
		ib_rightbButton.setImageResource(id);
	}
	public void setRightButtonClick(OnClickListener listener){
		ib_rightbButton.setOnClickListener(listener);
	}
	public void setLeftButtonOnclick(OnClickListener listener){
		ib_leftButton.setOnClickListener(listener);
	}
}
